#!/bin/bash

dbname=arc_six_dev
bossrec_train_table=bossrec_train
train_exposure_table=bossrec_train_exposure
train_positive_table=bossrec_train_positive
train_negative_table=bossrec_train_negative
train_tmp_table=bossrec_train_tmp
train_final_table=bossrec_train_final
success_day_table=bossrec_success_day
scenario_mapping_table=arc.scenario_mapping


only_tree_main(){
    calc_date=$1
    sessionid_lid $calc_date
    action_det_addf $calc_date
    exposure_filter $calc_date
}


main(){
    calc_date=$1
    last_1day=`date -d "$calc_date -1days" +%Y-%m-%d`
    last_2day=`date -d "$calc_date -2days" +%Y-%m-%d`
    last_3day=`date -d "$calc_date -3days" +%Y-%m-%d`
    date_num=`date -d "$calc_date" +%Y%m%d`

    sessionid_lid $calc_date
    action_det_addf $calc_date
    exposure_filter $calc_date
    gen_success $calc_date
    update_success $calc_date $calc_date
    update_success $calc_date $last_1day
    update_success $calc_date $last_2day
    update_success $calc_date $last_3day

    positive_sample_day $calc_date $calc_date 0
    positive_sample_day $calc_date $last_1day 1
    positive_sample_day $calc_date $last_2day 2
    positive_sample_day $calc_date $last_3day 3

    sql="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    drop table if exists positive_sample_jobid$date_num;
    create table positive_sample_jobid$date_num as 
    select distinct job_id from ${train_positive_table} where ds = '${calc_date}'
    ;"
#    echo -e "${sql}"
    hive -e "${sql}"

    negative_sample_day $calc_date $calc_date 0
    negative_sample_day $calc_date $last_1day 1
    negative_sample_day $calc_date $last_2day 2
    negative_sample_day $calc_date $last_3day 3

    hive -e "drop table if exists ${dbname}.positive_sample_jobid$date_num;"

    neg_output=/user/arc_six/pos_neg_sample/neg_sample_out/$calc_date
    hadoop fs -test -e ${neg_output}
    if [ $? -eq 0 ]; then
      echo "${neg_output} directory is exist, need to delete it!!"
      hadoop fs -rm -r ${neg_output}
    else
      echo "${neg_output} directory is not exist."
    fi

#    yarn jar phoenix-algo-1.8.0-SNAPSHOT.jar com.kanzhun.phoenix.algo.sample.BossRcdNegativeSample -D mapred.reduce.tasks=10 -Dmapreduce.job.queuename=boss.arc.six.vip -input /user/datastar/arc/six/warehouse/${dbname}/${train_negative_table}/ds=${calc_date}/ -output ${neg_output} -date ${calc_date}
    yarn jar phoenix-algo-1.8.0-SNAPSHOT.jar com.kanzhun.phoenix.algo.sample.BossRcdNegativeSampleNew -D mapred.reduce.tasks=10 -Dmapreduce.job.queuename=boss.arc.six.vip -negin /user/datastar/arc/six/warehouse/${dbname}/${train_negative_table}/ds=${calc_date}/ -usedin /user/datastar/arc/six/warehouse/${dbname}/bossrec_train_tmp/ds=${last_1day}/ -output ${neg_output} -date ${calc_date}

    train_data_dir=/user/arc_six/pos_neg_sample/train_data_out/$calc_date
    hadoop fs -test -e ${train_data_dir}
    if [ $? -eq 0 ]; then
      echo "${train_data_dir} directory is exist, need to delete it!!"
      hadoop fs -rm -r ${train_data_dir}
    else
      echo "${train_data_dir} directory is not exist."
    fi

    yarn jar phoenix-algo-1.8.0-SNAPSHOT.jar com.kanzhun.phoenix.algo.sample.BossRcdTrainData -D mapred.reduce.tasks=10 -Dmapreduce.job.queuename=boss.arc.six.vip -input /user/datastar/arc/six/warehouse/${dbname}/${train_positive_table}/ds=${calc_date}/,${neg_output} -output ${train_data_dir}

    hive -e "load data inpath '${train_data_dir}' overwrite into table ${dbname}.${train_tmp_table} partition(ds = '${calc_date}');"

    train_final $calc_date

    python download_data.py $calc_date arc_six_dev bossrec_train_final /data3/training_data/boss_rank

    source /data/arc_six/py_3_work/bin/activate
    python make_train_data.py $calc_date
    deactivate

    cd /data1/arc_six/transfer
    cat /data2/training_data/boss_rank/${calc_date}.merge | ./transfer_galaxy /data3/training_data/galaxy_data_new/$calc_date >> /data1/arc_six/transfer/result
}

# 特征日志关联曝光日志通过 sessionid 获取 lid
sessionid_lid(){
    day=$1

    sql_session_lid="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${bossrec_train_table} partition(ds = '${day}')
    select boss_l1code, boss_l2code, boss_position, b.combine_code as boss_combine_code, boss_city, geek_position, geek_city, c.combine_code as geek_combine_code, rtf.boss_id, rtf.job_id, rtf.geek_id, rtf.exp_id, page_no as page, rank, list_time, list_time as deal_time, coalesce(d.lid, rtf.lid), coalesce(d.engine, rtf.engine) as pk_class, rtf.sessionid, 'list' as deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, if(geek_major = '', 0, geek_major) as geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, 
    if(size(wy_arr) > 10, concat(wy_arr[0], ',', wy_arr[1], ',', wy_arr[2], ',', wy_arr[3], ',', wy_arr[4], ',', wy_arr[5], ',', wy_arr[6], ',', wy_arr[7], ',', wy_arr[8], ',', wy_arr[9]), if(size(wy_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', wy_arr))) as b2g_workyears_recent10,
    if(size(cl_arr) > 10, concat(cl_arr[0], ',', cl_arr[1], ',', cl_arr[2], ',', cl_arr[3], ',', cl_arr[4], ',', cl_arr[5], ',', cl_arr[6], ',', cl_arr[7], ',', cl_arr[8], ',', cl_arr[9]), if(size(cl_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', cl_arr))) as b2g_cmp_level_recent10,
    if(size(sl_arr) > 10, concat(sl_arr[0], ',', sl_arr[1], ',', sl_arr[2], ',', sl_arr[3], ',', sl_arr[4], ',', sl_arr[5], ',', sl_arr[6], ',', sl_arr[7], ',', sl_arr[8], ',', sl_arr[9]), if(size(sl_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', sl_arr))) as b2g_school_level_recent10,
    if(size(st_arr) > 10, concat(st_arr[0], ',', st_arr[1], ',', st_arr[2], ',', st_arr[3], ',', st_arr[4], ',', st_arr[5], ',', st_arr[6], ',', st_arr[7], ',', st_arr[8], ',', st_arr[9]), if(size(st_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', st_arr))) as b2g_school_type1_recent10,
    if(size(st2_arr) > 10, concat(st2_arr[0], ',', st2_arr[1], ',', st2_arr[2], ',', st2_arr[3], ',', st2_arr[4], ',', st2_arr[5], ',', st2_arr[6], ',', st2_arr[7], ',', st2_arr[8], ',', st2_arr[9]), if(size(st2_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', st2_arr))) as b2g_school_type2_recent10,
    if(size(de_arr) > 10, concat(de_arr[0], ',', de_arr[1], ',', de_arr[2], ',', de_arr[3], ',', de_arr[4], ',', de_arr[5], ',', de_arr[6], ',', de_arr[7], ',', de_arr[8], ',', de_arr[9]), if(size(de_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', de_arr))) as b2g_degree_recent10,
    if(size(ge_arr) > 10, concat(ge_arr[0], ',', ge_arr[1], ',', ge_arr[2], ',', ge_arr[3], ',', ge_arr[4], ',', ge_arr[5], ',', ge_arr[6], ',', ge_arr[7], ',', ge_arr[8], ',', ge_arr[9]), if(size(ge_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', ge_arr))) as b2g_gender_recent10,
    if(size(as_arr) > 10, concat(as_arr[0], ',', as_arr[1], ',', as_arr[2], ',', as_arr[3], ',', as_arr[4], ',', as_arr[5], ',', as_arr[6], ',', as_arr[7], ',', as_arr[8], ',', as_arr[9]), if(size(as_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', as_arr))) as b2g_apply_status_recent10,
    if(size(sa_arr) > 10, concat(sa_arr[0], ',', sa_arr[1], ',', sa_arr[2], ',', sa_arr[3], ',', sa_arr[4], ',', sa_arr[5], ',', sa_arr[6], ',', sa_arr[7], ',', sa_arr[8], ',', sa_arr[9]), if(size(sa_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', sa_arr))) as b2g_salary_recent10, 
    if(size(bag_arr) > 10, concat(bag_arr[0], ',', bag_arr[1], ',', bag_arr[2], ',', bag_arr[3], ',', bag_arr[4], ',', bag_arr[5], ',', bag_arr[6], ',', bag_arr[7], ',', bag_arr[8], ',', bag_arr[9]), '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3') as boss_addf_geek_recent10, 
    if(size(bae_arr) > 10, concat(bae_arr[0], ',', bae_arr[1], ',', bae_arr[2], ',', bae_arr[3], ',', bae_arr[4], ',', bae_arr[5], ',', bae_arr[6], ',', bae_arr[7], ',', bae_arr[8], ',', bae_arr[9]), '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3') as boss_addf_expect_recent10, 
    if(size(jag_arr) > 10, concat(jag_arr[0], ',', jag_arr[1], ',', jag_arr[2], ',', jag_arr[3], ',', jag_arr[4], ',', jag_arr[5], ',', jag_arr[6], ',', jag_arr[7], ',', jag_arr[8], ',', jag_arr[9]), '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3') as job_addf_geek_recent10, 
    if(size(jae_arr) > 10, concat(jae_arr[0], ',', jae_arr[1], ',', jae_arr[2], ',', jae_arr[3], ',', jae_arr[4], ',', jae_arr[5], ',', jae_arr[6], ',', jae_arr[7], ',', jae_arr[8], ',', jae_arr[9]), '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3') as job_addf_expect_recent10, 
    if(size(bsg_arr) > 10, concat(bsg_arr[0], ',', bsg_arr[1], ',', bsg_arr[2], ',', bsg_arr[3], ',', bsg_arr[4], ',', bsg_arr[5], ',', bsg_arr[6], ',', bsg_arr[7], ',', bsg_arr[8], ',', bsg_arr[9]), '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3') as boss_success_geek_recent10, 
    d.platform, pmod(datediff('${day}', '1920-01-01') - 3, 7) as day_of_week, coalesce(m.cluster_code, 'S0') as cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid,
    if(size(age_arr) > 10, concat(age_arr[0], ',', age_arr[1], ',', age_arr[2], ',', age_arr[3], ',', age_arr[4], ',', age_arr[5], ',', age_arr[6], ',', age_arr[7], ',', age_arr[8], ',', age_arr[9]), if(size(age_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', age_arr))) as b2g_revage_recent10,
    if(size(pos_arr) > 10, concat(pos_arr[0], ',', pos_arr[1], ',', pos_arr[2], ',', pos_arr[3], ',', pos_arr[4], ',', pos_arr[5], ',', pos_arr[6], ',', pos_arr[7], ',', pos_arr[8], ',', pos_arr[9]), if(size(pos_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', pos_arr))) as b2g_position_recent10,
    if(size(pp_arr) > 10, concat(pp_arr[0], ',', pp_arr[1], ',', pp_arr[2], ',', pp_arr[3], ',', pp_arr[4], ',', pp_arr[5], ',', pp_arr[6], ',', pp_arr[7], ',', pp_arr[8], ',', pp_arr[9]), if(size(pp_arr) < 10, '-3,-3,-3,-3,-3,-3,-3,-3,-3,-3', concat_ws(',', pp_arr))) as b2g_paspos_recent10,
    geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, rcd_bz_type, rcd_list_source from
    (select sessionid, boss_id, job_id, geek_id, exp_id, page_no, rank, list_time, coalesce(features['125'], -3) as boss_position, coalesce(features['128'], -3) as boss_city, coalesce(features['118'], -3) as geek_position, coalesce(features['120'], -3) as geek_city, coalesce(features['174'], -3) as jl, coalesce(features['177'], -3) as jh, coalesce(features['130'], -3) as job_workyears, coalesce(features['171'], -3) as job_degree, coalesce(features['204'], '-1') as geek_gender, coalesce(features['210'], '-1') as geek_degree, coalesce(features['191'], '-1') as geek_school_level, coalesce(features['212'], '-1') as geek_cmp_level, coalesce(features['217'], '0') as geek_apply_status, coalesce(features['179'], '0') as geek_workyears, coalesce(features['289'], '0') as el, coalesce(features['292'], '0') as eh, coalesce(features['346'], '0') as b2g_degree_match, coalesce(features['345'], '0') as b2g_degree_rel_match, coalesce(features['337'], '0') as b2g_salary_match, coalesce(features['336'], '0') as b2g_salary_rel_match, coalesce(features['325'], '0') as b2g_workyears_match, coalesce(features['324'], '0') as b2g_workyears_rel_match, coalesce(features['330'], '0') as b2g_static_match, coalesce(features['329'], '0') as b2g_static_rel_match, coalesce(features['215'], '0') as geek_chat_s2_num_1d7, coalesce(features['461'], '0') as b2g_skill_match, coalesce(features['497'], '0') as b2g_w2v_pref_gof, coalesce(features['498'], '0') as b2g_w2v_orig_gof, coalesce(features['340'], '0') as b2g_pastpos_addf_rate, coalesce(features['844'], '0') as b2g_school_level_gof, coalesce(features['843'], '0') as b2g_school_type1_gof, coalesce(features['842'], '0') as b2g_school_type2_gof, coalesce(features['847'], '0') as b2g_fresh_graduate_gof, coalesce(features['848'], '0') as b2g_degree_gof, coalesce(features['846'], '0') as b2g_gender_gof, coalesce(features['849'], '0') as b2g_apply_status_gof, coalesce(features['201'], '15552000') as geek_min_active_tdiff, coalesce(features['199'], '15552000') as geek_min_chat_tdiff, coalesce(features['282'], '0') as exp_det_num_24h, coalesce(features['258'], '0') as exp_pas_addf_num_24h, coalesce(features['845'], '0') as b2g_salary_gof, coalesce(features['841'], '0') as b2g_workyears_gof, coalesce(features['850'], '0') as b2g_cmp_level_gof, coalesce(features['481'], '0') as b2g_pos_major_match, coalesce(features['395'], '0') as b2g_pos_workyears_major_match, coalesce(features['480'], '0') as b2g_pos_skill_match, coalesce(features['413'], '0') as b2g_position_similarity, coalesce(features['391'], '0') as boss_cmp_level, coalesce(features['421'], '0') as b2g_overseas_match, coalesce(features['422'], '0') as job_overseas_tag, coalesce(features['423'], '0') as geek_overseas_tag, coalesce(features['838'], '0') as b2g_resp_workyears_gof, coalesce(features['837'], '0') as b2g_resp_school_level_gof, coalesce(features['857'], '0') as g2b_cmp_level_gof, 
    coalesce(features['859'], '0') as g2b_degree_gof, coalesce(features['856'], '0') as g2b_salary_gof, coalesce(features['852'], '0') as g2b_workyears_gof, coalesce(features['855'], '0') as g2b_scale_gof, coalesce(features['854'], '0') as g2b_stage_gof, coalesce(features['853'], '0') as g2b_title_type_gof, coalesce(features['419'], '15552000') as exp_register_tdiff, coalesce(features['750'], '15552000') as geek_complete_tdiff, coalesce(features['462'], '0') as b2g_title_w2v_orig_gof, coalesce(features['468'], '0') as b2g_major_w2v_gof, coalesce(features['467'], '0') as b2g_school_w2v_gof, coalesce(features['504'], '-1') as b2g_work_distance, coalesce(features['431'], '-1') as geek_workdist_sensi, coalesce(features['514'], '0') as b2g_company_gof, coalesce(features['516'], '-1') as exp_f1_pas_cp_addf_rate_1d7, coalesce(features['515'], '') as geek_simpos_workyears, coalesce(features['489'], '19900') as geek_degree_new, coalesce(features['355'], '3') as title_type, coalesce(features['495'], '0') as g2b_w2v_pref_gof, coalesce(features['496'], '0') as g2b_w2v_orig_gof, coalesce(features['645'], '0') as b2g_cdssm_gof, coalesce(features['643'], '0') as b2g_pjenn_gof, coalesce(features['628'], '15552000') as exp_min_active_tdiff, coalesce(features['653'], '0') as b2g_pos_pastpos_similarity, coalesce(features['839'], '0') as b2g_age_gof, coalesce(features['840'], '0') as b2g_position_gof, coalesce(features['652'], '0') as b2g_pos_similarity, coalesce(features['650'], '0') as b2g_position_addf_rate, coalesce(features['624'], '0') as g2b_position_addf_rate, coalesce(features['651'], '0') as b2g_city_addf_rate,
    coalesce(features['723'], '0') as job_plist_times_14d, coalesce(features['721'], '0') as job_addfchat_times_7d, coalesce(features['720'], '0') as job_success_times_7d, coalesce(features['719'], '0') as job_det_times_7d, coalesce(features['718'], '0') as job_addf_pchat_times_7d, coalesce(features['717'], '0') as job_addf_success_times_7d, coalesce(features['716'], '0') as job_addf_times_7d, coalesce(features['715'], '0') as job_addfchat_times_2d, coalesce(features['714'], '0') as job_success_times_2d, coalesce(features['713'], '0') as job_det_times_2d, coalesce(features['712'], '0') as job_addf_pchat_times_2d, coalesce(features['711'], '0') as job_addf_success_times_2d, coalesce(features['710'], '0') as job_addf_times_2d, coalesce(features['709'], '0') as job_pdet_times_14d, coalesce(features['708'], '0') as job_paddf_times_14d, coalesce(features['707'], '0') as job_paddfchat_times_7d, coalesce(features['706'], '0') as job_psuccess_times_7d, coalesce(features['705'], '0') as job_pdet_times_7d, coalesce(features['704'], '0') as job_paddf_pchat_times_7d, coalesce(features['703'], '0') as job_paddf_success_times_7d, coalesce(features['702'], '0') as job_paddf_times_7d, coalesce(features['701'], '0') as job_paddfchat_times_2d, coalesce(features['700'], '0') as job_psuccess_times_2d, coalesce(features['699'], '0') as job_pdet_times_2d, coalesce(features['698'], '0') as job_paddf_pchat_times_2d, coalesce(features['697'], '0') as job_paddf_success_times_2d, coalesce(features['696'], '0') as boss_addfchat_times_2d, coalesce(features['695'], '0') as boss_det_times_2d, coalesce(features['694'], '0') as boss_addf_pchat_times_2d, coalesce(features['693'], '0') as boss_addf_success_times_2d, coalesce(features['692'], '0') as boss_addf_times_2d, coalesce(features['691'], '0') as boss_paddfchat_times_2d, coalesce(features['690'], '0') as boss_psuccess_times_2d, coalesce(features['689'], '0') as boss_pdet_times_2d, coalesce(features['688'], '0') as boss_paddf_pchat_times_2d, coalesce(features['687'], '0') as boss_paddf_success_times_2d, coalesce(features['665'], '0') as job_paddf_times_2d, coalesce(features['664'], '0') as boss_paddf_times_2d, coalesce(features['722'], '0') as geek_plist_times_14d, coalesce(features['686'], '0') as geek_addfchat_times_7d, coalesce(features['685'], '0') as geek_success_times_7d, coalesce(features['684'], '0') as geek_det_times_7d, coalesce(features['683'], '0') as geek_addf_pchat_times_7d, coalesce(features['682'], '0') as geek_addf_success_times_7d, coalesce(features['681'], '0') as geek_addf_times_7d, coalesce(features['680'], '0') as geek_addfchat_times_2d, coalesce(features['679'], '0') as geek_success_times_2d, coalesce(features['678'], '0') as geek_det_times_2d, coalesce(features['677'], '0') as geek_addf_pchat_times_2d, coalesce(features['676'], '0') as geek_addf_success_times_2d, coalesce(features['675'], '0') as geek_addf_times_2d, coalesce(features['674'], '0') as geek_pdet_times_14d, 
    coalesce(features['673'], '0') as geek_paddf_times_14d, coalesce(features['672'], '0') as geek_paddfchat_times_7d, coalesce(features['671'], '0') as geek_psuccess_times_7d, coalesce(features['670'], '0') as geek_pdet_times_7d, coalesce(features['669'], '0') as geek_paddf_pchat_times_7d, coalesce(features['668'], '0') as geek_paddf_success_times_7d, coalesce(features['667'], '0') as geek_paddf_times_7d, coalesce(features['666'], '0') as geek_paddfchat_times_2d, coalesce(features['663'], '0') as geek_psuccess_times_2d, coalesce(features['662'], '0') as geek_pdet_times_2d, coalesce(features['661'], '0') as geek_paddf_pchat_times_2d, coalesce(features['660'], '0') as geek_paddf_success_times_2d, coalesce(features['659'], '0') as geek_paddf_times_2d, coalesce(features['730'], '0') as boss_view_geek_14d, coalesce(features['731'], '0') as boss_det_geek_14d, coalesce(features['736'], '0') as boss_pview_geek_14d, coalesce(features['737'], '0') as boss_pdet_geek_14d, coalesce(features['768'], '0') as geek_addfchat_rate_2d, coalesce(features['769'], '0') as geek_success_rate_2d, coalesce(features['770'], '0') as geek_addf_pchat_rate_2d, coalesce(features['771'], '0') as geek_addf_success_rate_2d, coalesce(features['772'], '0') as geek_addf_rate_2d, coalesce(features['773'], '0') as geek_paddfchat_rate_2d, coalesce(features['776'], '0') as geek_psuccess_rate_2d, coalesce(features['777'], '0') as geek_paddf_pchat_rate_2d, coalesce(features['778'], '0') as geek_paddf_success_rate_2d, coalesce(features['779'], '0') as geek_paddf_rate_2d, coalesce(features['790'], '0') as geek_addfchat_rate_7d, coalesce(features['791'], '0') as geek_success_rate_7d, coalesce(features['792'], '0') as geek_addf_pchat_rate_7d, coalesce(features['793'], '0') as geek_addf_success_rate_7d, coalesce(features['794'], '0') as geek_addf_rate_7d, coalesce(features['795'], '0') as geek_paddfchat_rate_7d, coalesce(features['796'], '0') as geek_psuccess_rate_7d, coalesce(features['797'], '0') as geek_paddf_pchat_rate_7d, coalesce(features['798'], '0') as geek_paddf_success_rate_7d, coalesce(features['799'], '0') as geek_paddf_rate_7d, coalesce(features['802'], '0') as geek_pdet_rate_14d, coalesce(features['803'], '0') as geek_paddf_rate_14d, coalesce(features['751'], '0') as job_addfchat_rate_2d, coalesce(features['752'], '0') as job_success_rate_2d, coalesce(features['753'], '0') as job_addf_pchat_rate_2d, coalesce(features['754'], '0') as job_addf_success_rate_2d, coalesce(features['755'], '0') as job_addf_rate_2d, coalesce(features['756'], '0') as job_paddfchat_rate_2d, coalesce(features['757'], '0') as job_psuccess_rate_2d, coalesce(features['758'], '0') as job_paddf_pchat_rate_2d, coalesce(features['759'], '0') as job_paddf_success_rate_2d, coalesce(features['774'], '0') as job_paddf_rate_2d, coalesce(features['780'], '0') as job_addfchat_rate_7d, coalesce(features['781'], '0') as job_success_rate_7d, coalesce(features['782'], '0') as job_addf_pchat_rate_7d, 
    coalesce(features['783'], '0') as job_addf_success_rate_7d, coalesce(features['784'], '0') as job_addf_rate_7d, coalesce(features['785'], '0') as job_paddfchat_rate_7d, coalesce(features['786'], '0') as job_psuccess_rate_7d, coalesce(features['787'], '0') as job_paddf_pchat_rate_7d, coalesce(features['788'], '0') as job_paddf_success_rate_7d, coalesce(features['789'], '0') as job_paddf_rate_7d, coalesce(features['800'], '0') as job_pdet_rate_14d, coalesce(features['801'], '0') as job_paddf_rate_14d, coalesce(features['760'], '0') as boss_addfchat_rate_2d, coalesce(features['761'], '0') as boss_addf_pchat_rate_2d, coalesce(features['762'], '0') as boss_addf_success_rate_2d, coalesce(features['763'], '0') as boss_addf_rate_2d, coalesce(features['764'], '0') as boss_paddfchat_rate_2d, coalesce(features['765'], '0') as boss_psuccess_rate_2d, coalesce(features['766'], '0') as boss_paddf_pchat_rate_2d, coalesce(features['767'], '0') as boss_paddf_success_rate_2d, coalesce(features['775'], '0') as boss_paddf_rate_2d, coalesce(features['810'], '0') as b2g_airbnb_emb_gof_int, features['367'] as geek_fresh_graduate, features['368'] as geek_work_p, features['372'] as geek_school_type1, features['373'] as geek_school_type2, coalesce(features['400'], 0) as geek_major, split(features['433'], ':')[0] as geek_rev_work_year, features['590'] as geek_business_code, features['656'] as geek_job_hopping, features['724'] as geek_school_ids, features['363'] as boss_company, features['379'] as boss_bussiness_id, features['380'] as boss_district_code, features['381'] as boss_comp_industry, coalesce(features['382'], 0) as boss_comp_scale, features['383'] as boss_comp_stage, features['386'] as boss_subway_line_id, features['387'] as boss_subway_station_id, 
    split(regexp_replace(features['964'], '\\\\[|\\\\]', ''), ', ') as wy_arr, split(regexp_replace(features['965'], '\\\\[|\\\\]', ''), ', ') as cl_arr, split(regexp_replace(features['966'], '\\\\[|\\\\]', ''), ', ') as sl_arr, split(regexp_replace(features['967'], '\\\\[|\\\\]', ''), ', ') as st_arr, split(regexp_replace(features['968'], '\\\\[|\\\\]', ''), ', ') as st2_arr, split(regexp_replace(features['969'], '\\\\[|\\\\]', ''), ', ') as de_arr, split(regexp_replace(features['970'], '\\\\[|\\\\]', ''), ', ') as ge_arr, split(regexp_replace(features['971'], '\\\\[|\\\\]', ''), ', ') as as_arr, split(regexp_replace(features['972'], '\\\\[|\\\\]', ''), ', ') as sa_arr, split(regexp_replace(features['896'], '\\\\[|\\\\]', ''), ', ') as bag_arr, split(regexp_replace(features['897'], '\\\\[|\\\\]', ''), ', ') as bae_arr, split(regexp_replace(features['898'], '\\\\[|\\\\]', ''), ', ') as jag_arr, split(regexp_replace(features['899'], '\\\\[|\\\\]', ''), ', ') as jae_arr, split(regexp_replace(features['900'], '\\\\[|\\\\]', ''), ', ') as bsg_arr, 
    coalesce(features['139'], '0') as job_pas_addf_num_24h, coalesce(features['144'], '0') as job_list_num_1d3, coalesce(features['168'], '0') as job_det_num_24h, coalesce(features['1037'], '') as boss_company_kwid, coalesce(features['904'], '') as boss_l1code, coalesce(features['973'], '') as boss_l2code, split(regexp_replace(features['1127'], '\\\\[|\\\\]', ''), ', ') as age_arr, split(regexp_replace(features['1128'], '\\\\[|\\\\]', ''), ', ') as pos_arr, split(regexp_replace(features['1129'], '\\\\[|\\\\]', ''), ', ') as pp_arr, coalesce(features['399'], '') as geek_school_code, coalesce(features['473'], '0') as geek_age, coalesce(features['977'], '0') as geek_rev_age, coalesce(features['534'], '') as geek_latest_work_position_id, coalesce(features['974'], '') as geek_l1code, coalesce(features['975'], '') as geek_l2code, source as rcd_bz_type, sessionid as lid, case when source in ('f1_brcd', 'lat_brcd') then 'f1' when source = 'brcd_search' then 'bossadvancesearch' else '' end as engine,
    case when source = 'lat_brcd' then 1 when source = 'f2_brcd_new' then 2 when source = 'f2_brcd_seeme' then 3 when source = 'f2_brcd_interesting' then 4 when source = 'brcd_search' then 5 else 0 end as rcd_list_source from dwd_boss_flow.dwd_predict_sample_hi where ds = '${day}' and source in ('f1_brcd', 'lat_brcd', 'f2_brcd_new', 'f2_brcd_seeme', 'f2_brcd_interesting', 'brcd_search')
    ) rtf
    left join
    dw_bosszp.zp_position_config b
    on rtf.boss_position = b.l3_code
    left join
    dw_bosszp.zp_position_config c
    on rtf.geek_position = c.l3_code
    left join
    (select distinct uid, lid, engine, itemid, expectid, jobid, sessionid, case when platform = 'andriod' then 'Android' when platform = 'ios' then 'iOS' else platform end as platform from dw_bosszp.bg_list_actions_hourly where ds = '${day}' and bg = 1 and action = 'list-geek' and sessionid is not null) d
    on rtf.boss_id = d.uid and rtf.job_id = d.jobid and rtf.geek_id = d.itemid and rtf.exp_id = d.expectid and rtf.sessionid = d.sessionid
    left join ${scenario_mapping_table} m on m.city = rtf.boss_city and m.position = rtf.boss_position
    where rtf.geek_major REGEXP '[^0-9.]' = 0;
    ;"

#    echo -e "${sql_session_lid}"
    hive -e "${sql_session_lid}"
}

# 关联查看、开聊行为
action_det_addf(){
    day=$1

    sql_det_addf="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${bossrec_train_table} partition(ds = '${day}')
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, boss_id, a.job_id, a.geek_id, a.exp_id, page, rank, list_time, if(b.lid is null, deal_time, b.date_time) as deal_time, a.lid, pk_class, sessionid, if(b.lid is null, a.deal_type, if(b.deal_type = 1, 'det', 'addf')) as deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, rcd_bz_type, rcd_list_source from ${bossrec_train_table} a 
    left join
    (select uid, geek_id, exp_id, job_id, lid, max(date_time) as date_time, max(deal_type) as deal_type from 
      (select uid, actionp as geek_id, actionp2 as exp_id, actionp3 as job_id, split(actionp4, '\\\\.')[0] as lid, min(date_time) as date_time, 1 as deal_type from dw_bosszp.zp_detail where ds = '${day}' and bg = 1 group by uid, actionp, actionp2, actionp3, actionp4
      union all
      select uid, actionp as geek_id, actionp3 as exp_id, actionp2 as job_id, split(actionp4, '\\\\.')[0] as lid, min(date_time) as date_time, 2 as deal_type from dw_bosszp.zp_addfriend where ds = '${day}' and bg = 1 group by uid, actionp, actionp3, actionp2, actionp4
      ) t
    group by uid, geek_id, exp_id, job_id, lid
    ) b
    on a.lid = b.lid and a.exp_id = b.exp_id and a.job_id = b.job_id
    where a.ds = '${day}'
    ;"

#    echo -e "${sql_det_addf}"
    hive -e "${sql_det_addf}"
}

# 客户端曝光过滤
exposure_filter(){
    day=$1

    sql_train_exposure="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${train_exposure_table} partition(ds = '${day}')
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, boss_id, job_id, geek_id, exp_id, page, rank, list_time, deal_time, lid, pk_class, sessionid, deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, rcd_bz_type, rcd_list_source from ${bossrec_train_table} where ds = '${day}' and deal_type <> 'list'
    union all
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, boss_id, job_id, geek_id, exp_id, page, rank, list_time, deal_time, a.lid, pk_class, sessionid, deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, rcd_bz_type, rcd_list_source from ${bossrec_train_table} a
    join
    (select distinct jobid, expectid, split(lid, '\\\\.')[0] as lid from dw_bosszp.exposure_client where ds = '${day}' and bg = 1 and jobid is not null and expectid is not null and lid is not null
    union all 
    select distinct actionp as jobid, actionp2 as expectid, actionp4 as lid from dw_bosszp.web_exposure_client where ds = '${day}' and bg = 1 and actionp is not null and actionp2 is not null and actionp4 is not null
    ) ec
    on a.job_id = ec.jobid and a.exp_id = ec.expectid and a.lid = ec.lid
    where a.ds = '${day}' and a.deal_type = 'list'
    ;"

#    echo -e "${sql_train_exposure}"
    hive -e "${sql_train_exposure}"
}

# 每天的达成
gen_success(){
    day=$1

#    sql_success="use ${dbname};
#    set mapreduce.job.queuename=boss.arc.six.vip;
#    insert overwrite table ${success_day_table} partition(ds = '${day}')
#    select boss_id, geek_id, job_id, max(date_time) as date_time from 
#      (select uid as boss_id, actionp as geek_id, actionp5 as job_id, date_time from dw_bosszp.zp_success where ds = '${day}' and bg = 1
#      union all
#      select actionp as boss_id, uid as geek_id, actionp5 as job_id, date_time from dw_bosszp.zp_success where ds = '${day}' and bg = 0 and length(actionp2) < 1
#      union all
#      select actionp as boss_id, uid as geek_id, actionp2 as job_id, date_time from dw_bosszp.zp_success where ds = '${day}' and bg = 0 and (actionp5 = '0' or length(actionp5) < 1)
#      ) t
#     group by boss_id, geek_id, job_id
#     ;"
    sql_success="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${success_day_table} partition(ds = '${day}')
    select boss_id, geek_id, job_id, max(date_time) as date_time from
      (select uid as boss_id, actionp as geek_id, actionp5 as job_id, date_time from dw_bosszp.zp_success where ds = '${day}' and bg = 1
      union all
      select actionp as boss_id, uid as geek_id, case when action = 'chat-interview-accept' then actionp2 else actionp5 end as job_id, date_time from dw_bosszp.zp_success where ds = '${day}' and bg = 0
      )t
    group by boss_id, geek_id, job_id
    ;"

#    echo -e "${sql_success}"
    hive -e "${sql_success}"
}

# 每天达成状态
update_success(){
    success_date=$1
    day=$2

    sql_train_success="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${train_exposure_table} partition(ds = '${day}')
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, boss_id, job_id, geek_id, exp_id, page, rank, list_time, deal_time, lid, pk_class, sessionid, deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, rcd_bz_type, rcd_list_source from ${train_exposure_table} where ds = '${day}' and deal_type in ('list', 'det', 'success')
    union all
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, a.boss_id, a.job_id, a.geek_id, exp_id, page, rank, list_time, if(b.date_time is null, deal_time, b.date_time) as deal_time, lid, pk_class, sessionid, if(b.job_id is null, a.deal_type, 'success') as deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, rcd_bz_type, rcd_list_source from ${train_exposure_table} a
    left join
    (select boss_id, geek_id, job_id, date_time from ${success_day_table} where ds = '${success_date}') b
    on a.boss_id = b.boss_id and a.geek_id = b.geek_id and a.job_id = b.job_id
    where a.ds = '${day}' and a.deal_type = 'addf'
    ;"

#    echo -e "${sql_train_success}"
    hive -e "${sql_train_success}"
}

# 当天的正例
positive_sample_day(){
    day=$1
    interval_date=$2
    interval=$3

    sql="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${train_positive_table} partition(ds = '${day}', interval = ${interval})
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, a.boss_id, a.job_id, a.geek_id, exp_id, page, rank, list_time, deal_time, lid, pk_class, sessionid, deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate,
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code from ${train_exposure_table} a
    join
    (select boss_id, geek_id, job_id, date_time from ${success_day_table} where ds = '${day}') b
    on a.boss_id = b.boss_id and a.geek_id = b.geek_id and a.job_id = b.job_id
    where a.ds = '${interval_date}' and a.deal_type = 'success' and to_date(deal_time) = '${day}' and rcd_bz_type in ('f1_brcd', 'lat_brcd')
    ;"

#    echo -e "${sql}"
    hive -e "${sql}"
}

# 当天的负例
negative_sample_day(){
    day=$1
    interval_date=$2
    interval=$3
    date_num=`date -d "$day" +%Y%m%d`

    sql_neg="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${train_negative_table} partition(ds = '${day}', interval = ${interval})
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, a.boss_id, a.job_id, a.geek_id, exp_id, page, rank, list_time, deal_time, lid, pk_class, sessionid, deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate,
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, cluster_code, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code from ${train_exposure_table} a
    join
    positive_sample_jobid${date_num} b
    on a.job_id = b.job_id
    where a.ds = '${interval_date}' and a.deal_type <> 'success' and rcd_bz_type in ('f1_brcd', 'lat_brcd');
    ;"

#    echo -e "${sql_neg}"
    hive -e "${sql_neg}"
}

train_final(){
    day=$1

    sql="use ${dbname};
    set mapreduce.job.queuename=boss.arc.six.vip;
    insert overwrite table ${train_final_table} partition(ds = '${day}', cluster_code)
    select boss_l1code, boss_l2code, boss_position, boss_combine_code, boss_city, geek_position, geek_city, geek_combine_code, boss_id, job_id, geek_id, exp_id, page, rank, list_time, deal_time, lid, pk_class, sessionid, deal_type, jl, jh, job_workyears, job_degree, geek_gender, geek_degree, geek_school_level, geek_cmp_level, geek_apply_status, geek_workyears, el, eh, b2g_degree_match, b2g_degree_rel_match, b2g_salary_match, b2g_salary_rel_match, b2g_workyears_match, b2g_workyears_rel_match, b2g_static_match, b2g_static_rel_match, geek_chat_s2_num_1d7, b2g_skill_match, b2g_w2v_pref_gof, b2g_w2v_orig_gof, b2g_pastpos_addf_rate, b2g_school_level_gof, b2g_school_type1_gof, b2g_school_type2_gof, b2g_fresh_graduate_gof, b2g_degree_gof, b2g_gender_gof, b2g_apply_status_gof, geek_min_active_tdiff, geek_min_chat_tdiff, exp_det_num_24h, exp_pas_addf_num_24h, b2g_salary_gof, b2g_workyears_gof, b2g_cmp_level_gof, b2g_pos_major_match, b2g_pos_workyears_major_match, b2g_pos_skill_match, b2g_position_similarity, boss_cmp_level, b2g_overseas_match, job_overseas_tag, geek_overseas_tag, b2g_resp_workyears_gof, b2g_resp_school_level_gof, g2b_cmp_level_gof, g2b_degree_gof, g2b_salary_gof, g2b_workyears_gof, g2b_scale_gof, g2b_stage_gof, g2b_title_type_gof, exp_register_tdiff, geek_complete_tdiff, b2g_title_w2v_orig_gof, b2g_major_w2v_gof, b2g_school_w2v_gof, b2g_work_distance, geek_workdist_sensi, b2g_company_gof, exp_f1_pas_cp_addf_rate_1d7, geek_simpos_workyears, geek_degree_new, title_type, g2b_w2v_pref_gof, g2b_w2v_orig_gof, b2g_cdssm_gof, b2g_pjenn_gof, exp_min_active_tdiff, b2g_pos_pastpos_similarity, b2g_age_gof, b2g_position_gof, b2g_pos_similarity, b2g_position_addf_rate, g2b_position_addf_rate, b2g_city_addf_rate, 
    job_plist_times_14d, job_addfchat_times_7d, job_success_times_7d, job_det_times_7d, job_addf_pchat_times_7d, job_addf_success_times_7d, job_addf_times_7d, job_addfchat_times_2d, job_success_times_2d, job_det_times_2d, job_addf_pchat_times_2d, job_addf_success_times_2d, job_addf_times_2d, job_pdet_times_14d, job_paddf_times_14d, job_paddfchat_times_7d, job_psuccess_times_7d, job_pdet_times_7d, job_paddf_pchat_times_7d, job_paddf_success_times_7d, job_paddf_times_7d, job_paddfchat_times_2d, job_psuccess_times_2d, job_pdet_times_2d, job_paddf_pchat_times_2d, job_paddf_success_times_2d, boss_addfchat_times_2d, boss_det_times_2d, boss_addf_pchat_times_2d, boss_addf_success_times_2d, boss_addf_times_2d, boss_paddfchat_times_2d, boss_psuccess_times_2d, boss_pdet_times_2d, boss_paddf_pchat_times_2d, boss_paddf_success_times_2d, job_paddf_times_2d, boss_paddf_times_2d, geek_plist_times_14d, geek_addfchat_times_7d, geek_success_times_7d, geek_det_times_7d, geek_addf_pchat_times_7d, geek_addf_success_times_7d, geek_addf_times_7d, geek_addfchat_times_2d, geek_success_times_2d, geek_det_times_2d, geek_addf_pchat_times_2d, geek_addf_success_times_2d, geek_addf_times_2d, geek_pdet_times_14d, geek_paddf_times_14d, geek_paddfchat_times_7d, geek_psuccess_times_7d, geek_pdet_times_7d, geek_paddf_pchat_times_7d, geek_paddf_success_times_7d, geek_paddf_times_7d, geek_paddfchat_times_2d, geek_psuccess_times_2d, geek_pdet_times_2d, geek_paddf_pchat_times_2d, geek_paddf_success_times_2d, geek_paddf_times_2d, boss_view_geek_14d, boss_det_geek_14d, boss_pview_geek_14d, boss_pdet_geek_14d, geek_addfchat_rate_2d, geek_success_rate_2d, geek_addf_pchat_rate_2d, geek_addf_success_rate_2d, geek_addf_rate_2d, geek_paddfchat_rate_2d, geek_psuccess_rate_2d, geek_paddf_pchat_rate_2d, geek_paddf_success_rate_2d, geek_paddf_rate_2d, geek_addfchat_rate_7d, geek_success_rate_7d, geek_addf_pchat_rate_7d, geek_addf_success_rate_7d, geek_addf_rate_7d, geek_paddfchat_rate_7d, geek_psuccess_rate_7d, geek_paddf_pchat_rate_7d, geek_paddf_success_rate_7d, geek_paddf_rate_7d, geek_pdet_rate_14d, geek_paddf_rate_14d, job_addfchat_rate_2d, job_success_rate_2d, job_addf_pchat_rate_2d, job_addf_success_rate_2d, job_addf_rate_2d, job_paddfchat_rate_2d, job_psuccess_rate_2d, job_paddf_pchat_rate_2d, job_paddf_success_rate_2d, job_paddf_rate_2d, job_addfchat_rate_7d, job_success_rate_7d, job_addf_pchat_rate_7d, job_addf_success_rate_7d, job_addf_rate_7d, job_paddfchat_rate_7d, job_psuccess_rate_7d, job_paddf_pchat_rate_7d, job_paddf_success_rate_7d, job_paddf_rate_7d, job_pdet_rate_14d, job_paddf_rate_14d, boss_addfchat_rate_2d, boss_addf_pchat_rate_2d, boss_addf_success_rate_2d, boss_addf_rate_2d, boss_paddfchat_rate_2d, boss_psuccess_rate_2d, boss_paddf_pchat_rate_2d, boss_paddf_success_rate_2d, boss_paddf_rate_2d, 
    b2g_airbnb_emb_gof_int, geek_fresh_graduate, geek_work_p, geek_school_type1, geek_school_type2, geek_major, geek_rev_work_year, geek_business_code, geek_job_hopping, geek_school_ids, boss_company, boss_bussiness_id, boss_district_code, boss_comp_industry, boss_comp_scale, boss_comp_stage, boss_subway_line_id, boss_subway_station_id, b2g_workyears_recent10, b2g_cmp_level_recent10, b2g_school_level_recent10, b2g_school_type1_recent10, b2g_school_type2_recent10, b2g_degree_recent10, b2g_gender_recent10, b2g_apply_status_recent10, b2g_salary_recent10, boss_addf_geek_recent10, boss_addf_expect_recent10, job_addf_geek_recent10, job_addf_expect_recent10, boss_success_geek_recent10, platform, day_of_week, job_pas_addf_num_24h, job_list_num_1d3, job_det_num_24h, boss_company_kwid, b2g_revage_recent10, b2g_position_recent10, b2g_paspos_recent10, geek_school_code, geek_age, geek_rev_age, geek_latest_work_position_id, geek_l1code, geek_l2code, cluster_code from ${train_tmp_table} where ds = '${day}'
    ;"

    hive -e "${sql}"
}

# main $1
only_tree_main $1